const URl='http://211.149.167.185:24716:8989';
//const BASE_URl_TEST = 'http://211.149.167.185:24716:8989'/m1/5708658-5389884-d3d6fe3f

//使用GIT获取角色分页列表数据
export const getRolesPage = async () => {
    try {
        const res =await fetch(URL+'/roles/page?page=1&size=10');
        return res.json();

    }
    catch(error){
        console.log("error:"+error);
    }
}

//使用POST方法新增角色

export const postRoles= async()=>{
    const myHeaders = new Headers();
    myHeaders.append("Content-Type", "application/json");

    myHeaders.append('Authorization',
        'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJSW5mbyI6eyJ1c2VySWQiOjIsInVzZXJuYW1lIjoiYWRtaW4iLCJuaWNrbmFtZSI6Iuezu-e7n-euoeeQhuWRmGFkbWluIiwiZGVwdElkIjoxLCJyb2xlcyI6IkFETUlOIn0sImlzcyI6ImR5czYyMzAiLCJleHAiOjE3Mjg5MDk5MTgsIm5iZiI6MTcyODg3MzkyOCwiaWF0IjoxNzI4ODczOTE4fQ.9xhdL57Qs38Mlm0K-TCwgrQjET1ZS2jUZhIOob0-pGk',
    );
    const newRole = {
        id:200,
        name: "测试角色",
        code: "test",
        sort:20,
        status:20,
        dataScope:20,
    };
    const requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: JSON.stringify(newRole),
    };
    const res = await fetch(URl+'/roles', requestOptions);
    if(res.ok){
        return res.json();
    }else{
        throw new Error('新增角色失败');
    }

}